define(['table','form'], function (Table,Form) {
    let Controller = {
        index: function () {
            Table.init = {
                table_elem: 'list',
                tableId: 'list',
                requests: {
                    index_url: 'data.Data/index' + location.search,
                    destroy_url: 'data.Data/destroy' + location.search,
                    delete_url: 'data.Data/delete' + location.search,
                    recycle_url: 'data.Data/recycle' + location.search,
                    import_url:'data.Data/import'+location.search,
                    export_url:'data.Data/export'+location.search,
                    add_url:'data.Data/add'+location.search,
                    edit_url:'data.Data/edit'+location.search,
                    modify_url: 'data.Data/modify',
                    detail: {
                        type: 'even',
                        class: 'layui-btn-xs layui-btn-warm',
                        icon: 'layui-icon-add-circle-fine',
                        url: 'data.Data/detail',
                        text: __('Detail'),
                        title:  __('Detail'),
                        full:0,
                        width:'',
                        height:'',
                        hidden:false,
                        callback:async function (obj, row) {
                            var othis = $(this);
                            $.get(Fun.url("data.Data/detail?id="+row.data.id), function(res){
                                console.log(res)
                                Fun.toastr.success("ok")
                                Table.events.refresh(othis);
                            });
                            window.open(row.data.url, "_blank");
                        },
                    },
                    template: {
                        type: 'even',
                        class: 'layui-btn-xs layui-btn-warm',
                        icon: 'layui-icon-add-circle-fine',
                        url: 'data.Data/template',
                        text: __('template'),
                        title:  __('template'),
                        full:0,
                        width:'',
                        height:'',
                        hidden:false,
                        callback:async function (obj, row) {
                            window.open("http://8.138.145.207:3030/storage/upload/58导入表格示例-3.xlsx", "_blank");
                        },
                    },
                }
            }
            Table.render({
                elem: '#' + Table.init.table_elem,
                id: Table.init.tableId,
                url: Fun.url(Table.init.requests.index_url),
                init: Table.init,
                primaryKey:'id',
                toolbar: ['refresh','add','import','export','delete','template'],
                defaultToolbar: ['filter'], //头部工具栏右侧图标
                searchShow: true,  // 默认展示筛选条件
                rowDouble: false,    //双击编辑
                searchInput: false,  //搜索框
                min_height:200,
                cols: [[
                    {checkbox: true,},
                    {field: 'id', title: __('ID'),width: 50, sort: true, search: false},
                    {field: 'img', title: __('Img'),width: 270,  sort: false, templet: Table.templet.image,search: false},
                    {field: 'name', title: __('Name'), width: 150,align: 'center', search: true},
                    {field: 'province', title: __('Province'),width: 100, align: 'center', search: true},
                    {field: 'city', title: __('City'),width: 100, align: 'center', search: true},
                    {field: 'address1', title: __('Address1'), width: 150, align: 'center', search: true},
                    //{field: 'address2', title: __('Address2'), width: 150, align: 'center', search: true},
                    //{field: 'address3', title: __('Address3'), width: 150, align: 'center', search: true},
                    //{field: 'address4', title: __('Address4'),width: 150, align: 'center', search: true},
                    //{field: 'manage_status',width: 150,  title: __('Manage_status'), align: 'center', search: true},
                    //{field: 'describe', title: __('Describe'), align: 'center', search: false},
                    //{field: 'area', title: __('Area'),width: 100, align: 'center', search: false},
                    {field: 'rent', title: __('Rent'),width: 150, align: 'center', search: false},
                    {field: 'publish_time', title: __('PublishTime'), width: 200, align: 'center', search: true},
                    {field: 'get_time', title: __('GetTime'), width: 100, align: 'center', search: true},
                    {
                        field: 'create_time',
                        title: __('CreateTime'),
                        align: 'center',
                        timeType: 'datetime',
                        dateformat: 'yyyy-MM-dd HH:mm:ss',
                        searchdateformat: 'yyyy-MM-dd HH:mm:ss',
                        search: 'timerange',
                        //search: false,
                        templet: Table.templet.time,
                        sort: true,
                        searchOp: 'daterange',
                        width: 200,
                    },
                    {
                        field: 'confirm_status',
                        fixed:"right",
                        title: __('Confirm_status'),
                        filter: 'confirm_status',
                        width: 120,
                        search: 'select',
                        //search: false,
                        selectList: {1: __('已沟通'), 2: __('未沟通')},
                        templet: Table.templet.select,
                        tips: __('已沟通') + '|' + __('未沟通')
                    },
                    {
                        minWidth: 150,
                        fixed:"right",
                        align: "center",
                        title: __("Operat"),
                        init: Table.init,
                        templet: Table.templet.operat,
                        operat: [ "detail", "delete"]
                    },
                ]],
                limits: [10, 15, 20, 25, 50, 100,500],
                limit: 15,
                page: true,
                done: function (res, curr, count) {
                }
            });
            Table.api.bindEvent(Table.init.tableId);
        },
        add: function () {
            Controller.api.bindevent()
        },
        edit: function () {
            Controller.api.bindevent()
        },

        api: {
            bindevent: function () {
                Form.api.bindEvent($('form'))
            }
        }
    };
    return Controller;
});
